﻿package Chapter05;
public class SimpleDotCom {
	// 實體變數
	int [] locations = {-1,-1,-1};
	int numOfHit = 0;

	// 方法
	void setLocationCells(int[] locs) {
		locations = locs;
		return;
	}

	String checkYourself(String strGuess) {
		int guess = Integer.parseInt(strGuess);

		if (isHit(guess)) {
			numOfHit++;
			if (numOfHit == 3) {
				return "kill";
			}
			return "hit";
		}

		return "miss";
	}
	
	boolean isHit(int loc) {
		//for (int i = 0; i < locations.length; i++) {
		for (int cell : locations) {
			if (cell == loc) {
				return true;
			}
		}
		return false;
	}
	
	void removeCell(String cellId) {
	}
}
